<!-- 班级中重修学生页面 -->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="/css/font.css">
		<link rel="stylesheet" href="/css/xadmin.css">
	</head>

	<body>
		<div class="x-body" id="app">
             <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
           title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
          <span class="x-right" style="line-height:40px;float:left">共有数据：{{ pageInfo.total }} 条，当前{{ pageInfo.pageNum }} / {{ pageInfo.pages }}页</span>
             <input type="hidden" name="classId" th:attr="value=${classId}"/>
			<table class="layui-table">
				<thead>
					<tr>
					   <th width="20">
                            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                        </th>
						<th>学号</th>
                        <th>学生姓名</th>
                        <th>性别</th>
                        <th>籍贯</th>
                        <th width="150">操作</th>
				</thead>
				<tbody>
					<tr v-for="student in students">
				        <td>
                            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" :data-id='student.stuId' :data-stuNo="student.stuNo" :data-stuName="student.stuName"><i class="layui-icon">&#xe605;</i></div>
                        </td>
						<td>{{ student.stuNo }}</td>
                        <td>{{ student.stuName }}</td>
                        <td v-if="student.stuSex == 1">女</td>
                        <td v-if="student.stuSex == 2">男</td>
                        <td>{{ student.homeplace }}</td>
                        <td class="td-manage">
                            <button class="layui-btn layui-btn layui-btn-sm" onclick="open_studentScoreManager(this)" href="javascript:;"><i
                                 class="layui-icon">&#xe640;</i>重修成绩管理</button>
                        </td>
					</tr>
				</tbody>
			</table>
			<div class="page" style="margin-top: 10px !important;">
                 <div>
                   <a class="prev pageTxt" href="javascript:void(0)">上一页</a>
                   <a class="first pageTxt" href="javascript:void(0)">首页</a>
                   <template v-for="pageNum in pageInfo.navigatepageNums">
                       <a class="num" href="javascript:void(0)" v-if="pageInfo.pageNum != pageNum" :data="pageNum">{{ pageNum }}</a>
                       <span class="current" v-else :data="pageNum">{{ pageNum }}</span>
                   </template>
                   <a class="last pageTxt" href="javascript:void(0)">尾页</a>
                   <a class="next pageTxt" href="javascript:void(0)">下一页</a>
                 </div>
           </div>
		</div>
		<script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/vue.min.js"></script>
        <script type="text/javascript" src="/js/jquery.form.js"></script>
		<script>
			var vm = new Vue({
	            el : '#app',
	            data : {
	                // 当前班级下的所有需要重修的学生
	                students : "",
	                pageInfo: "",
	                // 当前班级id
	                classId: ""
	            },
	            created : function() {
	                this.classId = $("input[name='classId']").val();
	                // 获取当前班级下的所有需要重修的学生
	               this.listRetakeStudent(this.classId, 1);
	            },
	            methods : {
	            	listRetakeStudent : function(classId, pageNum) {
	                    var vm = this;
	                    $.ajax({
	                        url : "/sys/student/score/listRetakeStudent",
	                        data: {
	                        	classId: classId,
	                        	pageNum: pageNum
	                        },
	                        type : "get",
	                        success : function(result) {
	                            if (result.state) {
	                                vm.pageInfo = result.data;
	                                vm.students = result.data.list;
	                            } else {
	                                layui.use(['layer'], function(){
	                                    var layer = layui.layer
	                                    layer.msg(""+result.msg, {icon: 5});
	                                });
	                            }
	                        }
	                    });
	                }
	            }
	        });
			
			// 打开重修成绩管理页面
            function open_studentScoreManager(obj) {
            	var stuNo = $(obj).parents("tr").find("div:first").attr("data-stuNo");
            	var stuName = $(obj).parents("tr").find("div:first").attr("data-stuName");
                x_admin_show('重修成绩管理['+stuName+']','/sys/student/score/toRetake_stuCourse_list?stuNo=' + stuNo, 600, 430);
            }
			
			// 点击页码数，进行跳转
            $(".page").delegate(".num", "click", function() {
                var pageNum = $(this).attr("data");
                vm.listRetakeStudent(vm.classId, pageNum);
            });
            // 上一页
            $(".page").delegate(".prev", "click", function() {
                if (vm.pageInfo.hasPreviousPage) {
                    vm.listRetakeStudent(vm.classId, vm.pageInfo.pageNum - 1);
                }
            });
            // 下一页
            $(".page").delegate(".next", "click", function() {
                if (vm.pageInfo.hasNextPage) {
                    vm.listRetakeStudent(vm.classId, vm.pageInfo.pageNum + 1);
                }
            });
            // 首页
            $(".page").delegate(".first", "click", function() {
                if (!vm.pageInfo.isFirstPage) {
                    vm.listRetakeStudent(vm.classId, 1);
                }
            });
            // 尾页
            $(".page").delegate(".last", "click", function() {
                if (!vm.pageInfo.isLastPage) {
                    vm.listRetakeStudent(vm.classId, vm.pageInfo.pages);
                }
            });
		</script>
	</body>

</html>
